package lxy;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;

public class Workt3 {

    public static void t1()throws Exception{
        FileReader fr = new FileReader("1.txt");
        FileWriter fw = new FileWriter("2.txt");
        char[] chars = new char[1024];
        int len = 0;
        while ((len = fr.read(chars)) != -1){
            fw.write(chars,0,len);
            fw.flush();
        }
        fw.close();
        fr.close();
    }
    public static void t2() throws Exception{
        FileWriter fw = new FileWriter("1.txt",true);
        fw.write("\"abc\"");
        fw.close();
    }

    public static void t3() throws Exception{
        BufferedReader br = new BufferedReader(new FileReader("1.txt"));
        BufferedWriter bw = new BufferedWriter(new FileWriter("3.txt"));
        String str = null;
        int num = 0;
        while ((str = br.readLine()) != null){
            bw.write(str);
            bw.newLine();
            if (str.indexOf('a') != -1){
                System.out.println(str);
                num++;
            }
            bw.flush();
        }
        System.out.println("一个有" + num + "个");
    }
    public static void main(String[] args) throws Exception{
        t3();
    }
}
